{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#!/usr/bin/env python2.7\n",
    "# _*_ coding:utf-8 _*_\n",
    "\n",
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "proc_time = 0\n",
    "\n",
    "capture = cv.VideoCapture(0)                        # 创建一个VideoCapture对象\n",
    "\n",
    "while(True):\n",
    "    ret, frame = capture.read()                     # 一帧一帧读取视频\n",
    "\n",
    "    proc_time += 1\n",
    "    if (proc_time % 30) == 0:\n",
    "        proc_frame = frame\n",
    "        cv.imshow('frame', proc_frame)  # 显示结果\n",
    "        \n",
    "    if cv.waitKey(1) &0xFF == ord('q'):             # 按q停止\n",
    "        break\n",
    "\n",
    "capture.release()                                   # 释放cap,销毁窗口\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
